import { DELETE, GET, POST, PUT } from '@/utils/request'

/**
 * 获取所有讨论
 * @param {Number}  pageNum
 * @param {Number}  pageSize
 * @param {String} keyword
 * @param {String}  strategy 策略 hottest-最热, latest-最新（默认)
 */
export const getAllDiscussions = (params) => GET(`/post/keywords`, params)

/**
 * 获取讨论详细
 * @param {String}  postId
 */
export const getDiscussion = (postId) => GET(`/post/detail/${ postId }`)

/**
 * 发布讨论
 * @param {String}  title
 * @param {String}  content
 * @param {Number}  tagId
 */
export const postDiscussion = (data) => POST('/post', data)

/**
  * 删除讨论
  * @param {String}  postId
  */
export const deleteDiscussion = (postId) => DELETE(`/post/${ postId }`)

/**
  * 修改讨论
  * @param {String}  postId
  * @param {String}  title
  * @param {String}  content
  * @param {Number}  tagId
  */
export const putDiscussion = ({ postId, ...data }) => PUT(`/post/${ postId }`, data)

